package com.itheima.override;

public class Test1 {

    public static void main(String[] args) {

        Student s = new Student("张三", 18, "男");
        //直接输出对象，默认会调用Object的toString方法（可省略不写），返回对象的地址值
        System.out.println(s);
        System.out.println(s.toString());
    }
}

class Student {

    private String name;
    private int age;
    private String gender;

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                '}';
    }

    public Student() {

    }

    public Student(String name, int age, String gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

}
